package com.example.hyw.szysteam.presenter;

import com.example.hyw.szysteam.POJO.HttpResult;
import com.example.hyw.szysteam.POJO.Practice;
import com.example.hyw.szysteam.model.HomeWorkModel;
import com.example.hyw.szysteam.view.CreateHomeWorkActivity;
import com.example.hyw.szysteam.view.ScoreActivity;

import java.util.ArrayList;
import java.util.Date;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by HYW on 2018/6/14.
 */

public class CreateHomeWorkPresenter {
    HomeWorkModel homeWorkModel=new HomeWorkModel();
    CreateHomeWorkActivity createHomeWorkActivity;

    public CreateHomeWorkPresenter(CreateHomeWorkActivity createHomeWorkActivity) {
        this.createHomeWorkActivity = createHomeWorkActivity;
    }

    public void createHomeWork(String classid, String testname, String date, String practices){
        homeWorkModel.createHomeWork(classid,testname,date,practices)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<HttpResult<String>>() {
                    @Override
                    public void accept(HttpResult<String> stringHttpResult) throws Exception {
                        createHomeWorkActivity.success();
                    }
                });
    }
}
